package com.bit.book.service;

import com.bit.book.entity.UserInfo;
import com.bit.book.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;
    /**
     * 验证密码是否正确
     * @param name
     * @param password
     * @return
     */
    public Boolean checkPassword(String name, String password) {
        //1. 根据名称获取用户信息
        UserInfo userInfo = userMapper.selectUserByName(name);
        //2. 验证密码是否正确
        if (userInfo==null){
            log.warn("用户信息不存在, name:"+ name);
            return false;
        }
        return password.equals(userInfo.getPassword());
    }
}
